//
//  MoreSelectView.m
//  Mahjong
//
//  Created by KING on 16/9/1.
//  Copyright © 2016年 swift. All rights reserved.
//

#import "MoreSelectView.h"

@implementation MoreSelectView
-(instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        [self create];
    }
    return self;
}
-(void)create{
    
    self.oneButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.oneButton.frame = CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width / 2.0, 40);
    
    //    self.oneButton.titleLabel.font = [UIFont systemFontOfSize:0.037*[[UIScreen mainScreen] bounds].size.width];
    [self addSubview:self.oneButton];
    [self.oneButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [_oneButton setTitle:@"购物订单" forState:UIControlStateNormal];
    //    _oneButton.titleLabel.font = [UIFont systemFontOfSize:18];
    _oneButton.backgroundColor = [UIColor redColor];
    [_oneButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    
    
    self.twoButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.twoButton.frame = CGRectMake([[UIScreen mainScreen] bounds].size.width / 2.0, 0, [[UIScreen mainScreen] bounds].size.width / 2.0, 40);
    
    //    self.twoButton.titleLabel.font = [UIFont systemFontOfSize:0.037*[[UIScreen mainScreen] bounds].size.width];
    [self addSubview:self.twoButton];
    [self.twoButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    self.twoButton.backgroundColor = [UIColor whiteColor];
    [self.twoButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self.twoButton setTitle:@"定制订单" forState:UIControlStateNormal];
}
- (void)buttonAction:(UIButton *)btn{
    if (btn == self.oneButton) {
        [self.myDelegate oneSelectAction];
        self.oneButton.backgroundColor = [UIColor redColor];
        [self.oneButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.twoButton.backgroundColor = [UIColor whiteColor];
        [self.twoButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
    } else {
        [self.myDelegate twoSelectAction];
        self.oneButton.backgroundColor = [UIColor whiteColor];
        [self.oneButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        self.twoButton.backgroundColor = [UIColor redColor];
        [self.twoButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
